import 'package:flutter/material.dart';

class AnimatedPositionDirectionalDemo extends StatefulWidget {
  @override
  _AnimatedPositionDirectionalDemoState createState() =>
      _AnimatedPositionDirectionalDemoState();
}

class _AnimatedPositionDirectionalDemoState
    extends State<AnimatedPositionDirectionalDemo> {
  var _start = 10.0;
  @override
  Widget build(BuildContext context) {
    return Stack(
      alignment: Alignment.center,
      children: [
        AnimatedPositionedDirectional(
          start: _start,
          width: 50,
          height: 50,
          duration: Duration(seconds: 2),
          child: Container(color: Colors.red),
        ),
        RaisedButton(onPressed: () {
          setState(() {
            if (_start == 180) {
              _start = 30;
            } else {
              _start = 180;
            }
          });
        })
      ],
    );
  }
}
